home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Dr. Windows 3
/
dr win3.zip
/
dr win3
/
PROGRAMR
/
FLAT.ZIP
/
FLATDATA.C
< prev
next >
Wrap
C/C++ Source or Header
|
1993-07-09
|
11KB
|
573 lines
#define WIN31
#include <windows.h>
#include <bwcc.h>
#include "flatm.h"
#pragma hdrstop
#include "flatdata.h"
#include <stdlib.h>
#include <string.h>
#include "\wmemchec\memcheck.h"
/*--------------------------------------------
-
- FLATDATA.C for Flat Windows Program
-
- Maintains the data and shows how to extract
- info from the WIN.INI file
-
- Dennis R. Fischer
- Denam Systems
- 1115 Madison St. NE Suite 226
- Salem, Oregon 97303
-
- CompuServe 70405,1422
- Internet 70405.1422@compuserve.com
-
- Developed with Borland 3.1 Compiler
-
- Free for the taking but please give credit
- where credit is do
-
----------------------------------------------*/
struct tagFLATDATA fd;
struct tagTOTMONEY TotalMoney;
WORKTYPE Work;
HINSTANCE hInst;
DATEFORMATTYPE DateFormat=NoDateFormat;
char szDateMark[2] = {"/"};
BOOL bExtraDayZero = FALSE;
BOOL bExtraMonthZero = FALSE;
BOOL bHasCentury = FALSE;
DATEFORMATTYPE SetDateFormat(void)
{
/* Looks at the 'intl' section of WIN.INI and
sets the date variables */
char szTemp[11];
char ch, chDateMark;
LPSTR lpStr;
DATEFORMATTYPE df1, df2, df3;
BOOL bQuit;
int i, count;
/* Grab the short date seperator */
GetProfileString("intl", "sDate", "/", szDateMark, 2);
chDateMark = szDateMark[0];
/* Get the type of format */
DateFormat = MonDayYear;
df1 = NoDateFormat;
df2 = NoDateFormat;
df3 = NoDateFormat;
GetProfileString("intl", "sShortDate", "", szTemp, 10);
AnsiUpper(szTemp);
bExtraDayZero = FALSE;
bExtraMonthZero = FALSE;
bHasCentury = FALSE;
if (lstrlen(szTemp) > 0) {
i=0;
count = 0;
/* Does the short date (month) have a leading zero */
do{
if (szTemp[i] == 'M')
count++;
i++;
}while(szTemp[i]);
if (count > 1)
bExtraMonthZero = TRUE;
/* Does the short date (day) have a leading zero */
i=0;
count=0;
do{
if(szTemp[i] == 'D')
count++;
i++;
}while(szTemp[i]);
if (count > 1)
bExtraDayZero = TRUE;
/* Does short date include the century (01/01/9999) */
i=0;
count=0;
do{
if(szTemp[i] == 'Y')
count++;
i++;
}while(szTemp[i]);
if (count > 2)
bHasCentury = TRUE;
/* now check the date format */
lpStr = szTemp;
ch = szTemp[0];
if (ch == 'M') {
df1 = MonDayYear;
}
else {
if (ch == 'D')
df1 = DayMonYear;
else {
if (ch == 'Y')
df1 = YearMonDay;
}
}
/* Get 2nd part */
bQuit = FALSE;
do{
lpStr = AnsiNext(lpStr);
ch = lpStr[0];
if (ch == chDateMark)
bQuit = TRUE;
if (ch == '\0')
bQuit = TRUE;
}while (!bQuit);
if (ch != '\0') {
lpStr = AnsiNext(lpStr);
ch = lpStr[0];
if (ch == 'M') {
df2 = MonDayYear;
}
else {
if (ch == 'D')
df2 = DayMonYear;
else
if (ch == 'Y')
df2 = YearMonDay;
}
/* Get 3rd part */
bQuit = FALSE;
do{
lpStr = AnsiNext(lpStr);
ch = lpStr[0];
if (ch == chDateMark)
bQuit = TRUE;
if (ch == '\0')
bQuit = TRUE;
}while (!bQuit);
if (ch != '\0') {
lpStr = AnsiNext(lpStr);
ch = lpStr[0];
if (ch == 'M') {
df3 = MonDayYear;
}
else {
if (ch == 'D')
df3 = DayMonYear;
else
if (ch == 'Y')
df3 = YearMonDay;
}
}
}
if ((df1 != NoDateFormat) && (df2 != NoDateFormat) &&
(df3 != NoDateFormat)) {
switch (df1) {
case MonDayYear :
if (df2 == DayMonYear) {
DateFormat = MonDayYear;
}
else {
if (df2 == YearMonDay)
DateFormat = MonYearDay;
}
break;
case DayMonYear :
if (df2 == MonDayYear) {
DateFormat = DayMonYear;
}
else {
if (df2 == YearMonDay)
DateFormat = DayYearMon;
}
break;
case YearMonDay :
if (df2 == MonDayYear) {
DateFormat = YearMonDay;
}
else {
if (df2 == DayMonYear)
DateFormat = YearDayMon;
}
break;
default : break;
}
}
}
return DateFormat;
} /* SetDateFormat */
DATEFORMATTYPE GetDateFormat (void)
{
/* returns the date format */
if (DateFormat == NoDateFormat)
SetDateFormat();
return DateFormat;
}
char *GetDateMark (void)
{
/* this is the mark that is located between the
month, day, and year (i.e. if the date format
was month/day/year (mm/dd/yy) the DateMark
would be '/'
*/
return szDateMark;
}
BOOL HasDayZero (void)
{
/* will day (on short date) that is less
than 10 include a leading zero */
return bExtraDayZero;
}
BOOL HasMonthZero (void)
{
/* will month (on short date) that is less
than 10 include a leading zero */
return bExtraMonthZero;
}
BOOL HasCentury (void)
{
/* will year (on short date) include the century */
return bHasCentury;
}
void SetInstance(HINSTANCE hInstance)
{
/* Save the program instance */
hInst = hInstance;
}
HINSTANCE GetInstance(void)
{
/* return the program instance */
return hInst;
}
void SetWork(WORKTYPE NewWork)
{
/* Saves the type of work the routines will do */
Work = NewWork;
}
WORKTYPE GetWork(void)
{
/* Returns the type of work the routines will do */
return Work;
}
BOOL GetUsed(void)
{
return fd.Used;
}
void GetName(LPSTR Name)
{
lstrcat(Name, fd.Name);
}
void GetCompany(LPSTR Company)
{
lstrcat(Company, fd.Company);
}
void GetAddress1(LPSTR Address)
{
lstrcat(Address, fd.Address1);
}
void GetAddress2(LPSTR Address)
{
lstrcat(Address, fd.Address2);
}
void GetCity(LPSTR City)
{
lstrcat(City, fd.City);
}
void GetState(LPSTR State)
{
lstrcat(State, fd.State);
}
void GetZip(LPSTR Zip)
{
lstrcat(Zip, fd.Zip);
}
void GetCountry(LPSTR Country)
{
lstrcat(Country, fd.Country);
}
void GetProduct(LPSTR Product)
{
lstrcat(Product, fd.Product);
}
void GetPriceDollar(LPSTR Dollar)
{
lstrcat(Dollar, fd.PriceDollar);
}
void GetPriceCent(LPSTR Cent)
{
lstrcat(Cent, fd.PriceCent);
}
void GetSoldVersion(LPSTR Version)
{
lstrcat(Version, fd.SoldVersion);
}
void GetUpdateVersion(LPSTR Version)
{
lstrcat(Version, fd.UpdateVersion);
}
void GetDay(LPSTR Day)
{
lstrcat(Day, fd.Day);
}
void GetMonth(LPSTR Month)
{
lstrcat(Month, fd.Month);
}
void GetYear(LPSTR Year)
{
lstrcat(Year, fd.Year);
}
void NulData(void)
{
fd.Name[0]=(char)0;
fd.Company[0]=(char)0;
fd.Address1[0]=(char)0;
fd.Address2[0]=(char)0;
fd.City[0]=(char)0;
fd.State[0]=(char)0;
fd.Zip[0]=(char)0;
fd.Country[0]=(char)0;
fd.Invoice[0]=(char)0;
fd.Product[0]=(char)0;
fd.PriceDollar[0]=(char)0;
fd.PriceCent[0]=(char)0;
fd.SoldVersion[0]=(char)0;
fd.UpdateVersion[0]=(char)0;
fd.Day[0] = (char)0;
fd.Month[0] = (char)0;
fd.Year[0] = (char)0;
fd.Used = FALSE;
}
void SetUsed(BOOL use)
{
fd.Used = use;
}
void SetName(LPCSTR ne)
{
lstrcpy(fd.Name, ne);
}
void SetCompany(LPCSTR cy)
{
lstrcpy(fd.Company, cy);
}
void SetAddress1(LPCSTR as)
{
lstrcpy(fd.Address1, as);
}
void SetAddress2(LPCSTR as)
{
lstrcpy(fd.Address2, as);
}
void SetCity(LPCSTR cy)
{
lstrcpy(fd.City, cy);
}
void SetState(LPCSTR se)
{
lstrcpy(fd.State, se);
}
void SetZip(LPCSTR zp)
{
lstrcpy(fd.Zip, zp);
}
void SetCountry(LPCSTR cy)
{
lstrcpy(fd.Country, cy);
}
void SetProduct(LPCSTR pt)
{
lstrcpy(fd.Product, pt);
}
void SetDay(LPCSTR dy)
{
lstrcpy(fd.Day, dy);
}
void SetMonth(LPCSTR mh)
{
lstrcpy(fd.Month, mh);
}
void SetYear(LPCSTR yr)
{
lstrcpy(fd.Year, yr);
}
void SetDollar(LPCSTR dr)
{
lstrcpy(fd.PriceDollar, dr);
}
void SetCent(LPCSTR ct)
{
char ts[6];
lstrcpy(ts, ct);
ts[2]=(char)0;
ls